package swtElements;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;

import view.editors.CommentEditor;
import view.editors.DocumentEditor;

public class MyText {
	
	Text text;
	
	public MyText(MyComposite client, int setSize, boolean editor){
		if(editor == false){
			GridData gridData = new GridData();
			gridData.horizontalIndent = 0;
			gridData.widthHint = setSize;

			this.text = new Text(client.getComposite(), SWT.BORDER);
			text.setLayoutData(gridData);
		}else{
			GridData gridData = new GridData(GridData.FILL_BOTH);
			gridData.minimumHeight = setSize;
			
			this.text = new Text(client.getComposite(), SWT.BORDER | SWT.MULTI | SWT.V_SCROLL
					| SWT.H_SCROLL);
			text.setLayoutData(gridData);
		}
	}

	public String getText() {
		return text.getText();
	}
	
	public void setText(String string){
		text.setText(string);
	}

	public void addModifyListener(DocumentEditor documentEditor) {
		text.addModifyListener(documentEditor);
	}

	public void removeModifyListener(DocumentEditor documentEditor) {
		text.removeModifyListener(documentEditor);
	}

	public void addModifyListener(CommentEditor commentEditor) {
		text.addModifyListener(commentEditor);
	}

	public void removeModifyListener(CommentEditor commentEditor) {
		text.removeModifyListener(commentEditor);
	}

}
